package com.atguigu.edu.realtime.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @ClassName PhoenixUtil
 * @Description TODO 操作phoenix的工具类
 * @Author AFei
 * @Date 2022/9/4 16:20
 * @Version 1.0
 */
public class PhoenixUtil {
    // 执行sql语句的方法
    public static void executeSql(Connection conn , String sql) {
        PreparedStatement ps =null;
        try {
            // 获取数据库操作对象
            ps = conn.prepareStatement(sql);
            // 执行sql语句
            ps.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if (ps != null) {
                try {
                    ps.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
